﻿#region Imports
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime;
using System.Windows.Forms;
using CommonUtilities.Extensions;
using CommonUtilities.Properties;
using CommonUtilities.Util;
#endregion

namespace CommonUtilities.Messages
{
    /// <summary>
    /// Displays a message box that can contain text, buttons, and symbols that inform and instruct the user.
    /// </summary>
    public static class MessageBoxUtil
    {
        #region Declarations
        private const bool defaultDebugMode = false;
        #endregion

        #region Methods
        #region Error info
        private static void AddDebugInfo(ref string text, ref string caption)
        {
            //do
            //{
            //    ;
            //} while (true);

            StackTrace stkTrace = new StackTrace();
            StackFrame[] stkFrames = stkTrace.GetFrames();

            List<string> discardNames = new List<string>();
            //discardNames.Add("AddDebugInfo");
            //discardNames.AddRange(typeof(MessageBoxUtil).GetMethods().Select(mb => mb.Name).Distinct());
            //discardNames.AddRange(typeof(MessageBoxUtil).GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Select(mb => mb.Name).Distinct());
            discardNames.AddRange(Utilities.GetMethods(typeof(MessageBoxUtil)).Select(mb => mb.Name).Distinct());

            caption = "Debug :: " + caption;
            foreach (StackFrame frame in stkFrames)
            {
                if (!discardNames.Contains(frame.GetMethod().Name))
                {
                    text = Resources.Msg_DebugInfo.FormatTextFromParams(Utilities.GenerateDebugInfo(frame), text);
                    // "Debug Info:" + Utilities.cNewLine + "{1}" + Utilities.cNewLine + Utilities.cNewLine + "Org. Msg:" + Utilities.cNewLine + "{2}"; // RKD
                    // "Debug Info:\r\n" + GenerateInfo(frame) + "\r\n\r\nOrg. Msg:\r\n" + text; // RKD
                    break;
                }
            }
        }

        private static void AddDebugInfo(ref string text)
        {
            string caption = "";
            AddDebugInfo(ref text, ref caption);
        }

        public static string ToString()
        {
            return Utilities.ToString(typeof(MessageBoxUtil));
        }
        #endregion

        #region MessageBox method overloads
        /// <summary>
        /// Displays a message box with specified text.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
        public static DialogResult Show(bool? isDebug, string text)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text);
            return MessageBox.Show(text);
        }

        /// <summary>
        /// Displays a message box in front of the specified object and with the specified text.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="owner">An implementation of System.Windows.Forms.IWin32Window that will own the modal dialog box.</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
        public static DialogResult Show(bool? isDebug, IWin32Window owner, string text)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text);
            return MessageBox.Show(owner, text);
        }

        /// <summary>
        /// Displays a message box with specified text and caption.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
        [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
        public static DialogResult Show(bool? isDebug, string text, string caption)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(text, caption);
        }

        /// <summary>
        /// Displays a message box in front of the specified object and with the specified text and caption.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="owner">An implementation of System.Windows.Forms.IWin32Window that will own the modal dialog box.</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <returns></returns>
        [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
        public static DialogResult Show(bool? isDebug, IWin32Window owner, string text, string caption)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(owner, text, caption);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     The buttons parameter specified is not a member of System.Windows.Forms.MessageBoxButtons.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.

        /// <summary>
        /// Displays a message box with specified text, caption, and buttons.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <returns></returns>
        [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
        public static DialogResult Show(bool? isDebug, string text, string caption, MessageBoxButtons buttons)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(text, caption, buttons);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     buttons is not a member of System.Windows.Forms.MessageBoxButtons.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.

        /// <summary>
        /// Displays a message box in front of the specified object and with the specified text, caption, and buttons.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="owner">An implementation of System.Windows.Forms.IWin32Window that will own the modal dialog box.</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <returns></returns>
        [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
        public static DialogResult Show(bool? isDebug, IWin32Window owner, string text, string caption, MessageBoxButtons buttons)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(owner, text, caption, buttons);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     The buttons parameter specified is not a member of System.Windows.Forms.MessageBoxButtons.-or-
        //     The icon parameter specified is not a member of System.Windows.Forms.MessageBoxIcon.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.

        /// <summary>
        /// Displays a message box with specified text, caption, buttons, and icon.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the System.Windows.Forms.MessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <returns></returns>
        [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
        public static DialogResult Show(bool? isDebug, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(text, caption, buttons, icon);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     buttons is not a member of System.Windows.Forms.MessageBoxButtons.-or- icon
        //     is not a member of System.Windows.Forms.MessageBoxIcon.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.

        /// <summary>
        /// Displays a message box in front of the specified object and with the specified text, caption, buttons, and icon.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="owner">An implementation of System.Windows.Forms.IWin32Window that will own the modal dialog box.</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the System.Windows.Forms.MessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <returns></returns>
        [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
        public static DialogResult Show(bool? isDebug, IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(owner, text, caption, buttons, icon);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     buttons is not a member of System.Windows.Forms.MessageBoxButtons.-or- icon
        //     is not a member of System.Windows.Forms.MessageBoxIcon.-or- defaultButton
        //     is not a member of System.Windows.Forms.MessageBoxDefaultButton.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.

        /// <summary>
        /// Displays a message box with the specified text, caption, buttons, icon, and default button.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the System.Windows.Forms.MessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
        /// <returns></returns>
        [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
        public static DialogResult Show(bool? isDebug, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(text, caption, buttons, icon, defaultButton);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     buttons is not a member of System.Windows.Forms.MessageBoxButtons.-or- icon
        //     is not a member of System.Windows.Forms.MessageBoxIcon.-or- defaultButton
        //     is not a member of System.Windows.Forms.MessageBoxDefaultButton.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.

        /// <summary>
        /// Displays a message box in front of the specified object and with the specified text, caption, buttons, icon, and default button.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="owner">An implementation of System.Windows.Forms.IWin32Window that will own the modal dialog box.</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the System.Windows.Forms.MessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
        /// <returns></returns>
        [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
        public static DialogResult Show(bool? isDebug, IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(owner, text, caption, buttons, icon, defaultButton);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     buttons is not a member of System.Windows.Forms.MessageBoxButtons.-or- icon
        //     is not a member of System.Windows.Forms.MessageBoxIcon.-or- The defaultButton
        //     specified is not a member of System.Windows.Forms.MessageBoxDefaultButton.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.
        //
        //   System.ArgumentException:
        //     options specified both System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly
        //     and System.Windows.Forms.MessageBoxOptions.ServiceNotification.-or- buttons
        //     specified an invalid combination of System.Windows.Forms.MessageBoxButtons.

        /// <summary>
        /// Displays a message box with the specified text, caption, buttons, icon, default button, and options.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the System.Windows.Forms.MessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
        /// <param name="options">One of the System.Windows.Forms.MessageBoxOptions values that specifies which display and association options will be used for the message box. You may pass in 0 if you wish to use the defaults.</param>
        /// <returns></returns>
        [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
        public static DialogResult Show(bool? isDebug, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(text, caption, buttons, icon, defaultButton, options);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     buttons is not a member of System.Windows.Forms.MessageBoxButtons.-or- icon
        //     is not a member of System.Windows.Forms.MessageBoxIcon.-or- defaultButton
        //     is not a member of System.Windows.Forms.MessageBoxDefaultButton.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.
        //
        //   System.ArgumentException:
        //     options specified both System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly
        //     and System.Windows.Forms.MessageBoxOptions.ServiceNotification.-or- options
        //     specified System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly or System.Windows.Forms.MessageBoxOptions.ServiceNotification
        //     and specified a value in the owner parameter. These two options should be
        //     used only if you invoke the version of this method that does not take an
        //     owner parameter.-or- buttons specified an invalid combination of System.Windows.Forms.MessageBoxButtons.

        /// <summary>
        /// Displays a message box in front of the specified object and with the specified text, caption, buttons, icon, default button, and options.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="owner">An implementation of System.Windows.Forms.IWin32Window that will own the modal dialog box.</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the System.Windows.Forms.MessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
        /// <param name="options">One of the System.Windows.Forms.MessageBoxOptions values that specifies which display and association options will be used for the message box. You may pass in 0 if you wish to use the defaults.</param>
        /// <returns></returns>
        [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
        public static DialogResult Show(bool? isDebug, IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     buttons is not a member of System.Windows.Forms.MessageBoxButtons.-or- icon
        //     is not a member of System.Windows.Forms.MessageBoxIcon.-or- The defaultButton
        //     specified is not a member of System.Windows.Forms.MessageBoxDefaultButton.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.
        //
        //   System.ArgumentException:
        //     options specified both System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly
        //     and System.Windows.Forms.MessageBoxOptions.ServiceNotification.-or- buttons
        //     specified an invalid combination of System.Windows.Forms.MessageBoxButtons.

        /// <summary>
        /// Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the System.Windows.Forms.MessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
        /// <param name="options">One of the System.Windows.Forms.MessageBoxOptions values that specifies which display and association options will be used for the message box. You may pass in 0 if you wish to use the defaults.</param>
        /// <param name="displayHelpButton">true to show the Help button; otherwise, false. The default is false.</param>
        /// <returns></returns>
        [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
        public static DialogResult Show(bool? isDebug, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, bool displayHelpButton)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(text, caption, buttons, icon, defaultButton, options, displayHelpButton);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     buttons is not a member of System.Windows.Forms.MessageBoxButtons.-or- icon
        //     is not a member of System.Windows.Forms.MessageBoxIcon.-or- The defaultButton
        //     specified is not a member of System.Windows.Forms.MessageBoxDefaultButton.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.
        //
        //   System.ArgumentException:
        //     options specified both System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly
        //     and System.Windows.Forms.MessageBoxOptions.ServiceNotification.-or- buttons
        //     specified an invalid combination of System.Windows.Forms.MessageBoxButtons.

        /// <summary>
        /// Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the System.Windows.Forms.MessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
        /// <param name="options">One of the System.Windows.Forms.MessageBoxOptions values that specifies which display and association options will be used for the message box. You may pass in 0 if you wish to use the defaults.</param>
        /// <param name="helpFilePath">The path and name of the Help file to display when the user clicks the Help button.</param>
        /// <returns></returns>
        public static DialogResult Show(bool? isDebug, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(text, caption, buttons, icon, defaultButton, options, helpFilePath);
        }

        //
        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     buttons is not a member of System.Windows.Forms.MessageBoxButtons.-or- icon
        //     is not a member of System.Windows.Forms.MessageBoxIcon.-or- The defaultButton
        //     specified is not a member of System.Windows.Forms.MessageBoxDefaultButton.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.
        //
        //   System.ArgumentException:
        //     options specified both System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly
        //     and System.Windows.Forms.MessageBoxOptions.ServiceNotification.-or- buttons
        //     specified an invalid combination of System.Windows.Forms.MessageBoxButtons.

        /// <summary>
        /// Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="owner">An implementation of System.Windows.Forms.IWin32Window that will own the modal dialog box.</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the System.Windows.Forms.MessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
        /// <param name="options">One of the System.Windows.Forms.MessageBoxOptions values that specifies which display and association options will be used for the message box. You may pass in 0 if you wish to use the defaults.</param>
        /// <param name="helpFilePath">The path and name of the Help file to display when the user clicks the Help button.</param>
        /// <returns></returns>
        public static DialogResult Show(bool? isDebug, IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options, helpFilePath);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     buttons is not a member of System.Windows.Forms.MessageBoxButtons.-or- icon
        //     is not a member of System.Windows.Forms.MessageBoxIcon.-or- The defaultButton
        //     specified is not a member of System.Windows.Forms.MessageBoxDefaultButton.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.
        //
        //   System.ArgumentException:
        //     options specified both System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly
        //     and System.Windows.Forms.MessageBoxOptions.ServiceNotification.-or- buttons
        //     specified an invalid combination of System.Windows.Forms.MessageBoxButtons.

        /// <summary>
        /// Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file and HelpNavigator.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the System.Windows.Forms.MessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
        /// <param name="options">One of the System.Windows.Forms.MessageBoxOptions values that specifies which display and association options will be used for the message box. You may pass in 0 if you wish to use the defaults.</param>
        /// <param name="helpFilePath">The path and name of the Help file to display when the user clicks the Help button.</param>
        /// <param name="navigator">One of the System.Windows.Forms.HelpNavigator values.</param>
        /// <returns></returns>
        public static DialogResult Show(bool? isDebug, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(text, caption, buttons, icon, defaultButton, options, helpFilePath, navigator);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     buttons is not a member of System.Windows.Forms.MessageBoxButtons.-or- icon
        //     is not a member of System.Windows.Forms.MessageBoxIcon.-or- The defaultButton
        //     specified is not a member of System.Windows.Forms.MessageBoxDefaultButton.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.
        //
        //   System.ArgumentException:
        //     options specified both System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly
        //     and System.Windows.Forms.MessageBoxOptions.ServiceNotification.-or- buttons
        //     specified an invalid combination of System.Windows.Forms.MessageBoxButtons.

        /// <summary>
        /// Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file and Help keyword.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the System.Windows.Forms.MessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
        /// <param name="options">One of the System.Windows.Forms.MessageBoxOptions values that specifies which display and association options will be used for the message box. You may pass in 0 if you wish to use the defaults.</param>
        /// <param name="helpFilePath">The path and name of the Help file to display when the user clicks the Help button.</param>
        /// <param name="keyword">The Help keyword to display when the user clicks the Help button.</param>
        /// <returns></returns>
        public static DialogResult Show(bool? isDebug, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, string keyword)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(text, caption, buttons, icon, defaultButton, options, helpFilePath, keyword);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     buttons is not a member of System.Windows.Forms.MessageBoxButtons.-or- icon
        //     is not a member of System.Windows.Forms.MessageBoxIcon.-or- The defaultButton
        //     specified is not a member of System.Windows.Forms.MessageBoxDefaultButton.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.
        //
        //   System.ArgumentException:
        //     options specified both System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly
        //     and System.Windows.Forms.MessageBoxOptions.ServiceNotification.-or- buttons
        //     specified an invalid combination of System.Windows.Forms.MessageBoxButtons.

        /// <summary>
        /// Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file and HelpNavigator.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="owner">An implementation of System.Windows.Forms.IWin32Window that will own the modal dialog box.</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the System.Windows.Forms.MessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
        /// <param name="options">One of the System.Windows.Forms.MessageBoxOptions values that specifies which display and association options will be used for the message box. You may pass in 0 if you wish to use the defaults.</param>
        /// <param name="helpFilePath">The path and name of the Help file to display when the user clicks the Help button.</param>
        /// <param name="navigator">One of the System.Windows.Forms.HelpNavigator values.</param>
        /// <returns></returns>
        public static DialogResult Show(bool? isDebug, IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options, helpFilePath, navigator);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     buttons is not a member of System.Windows.Forms.MessageBoxButtons.-or- icon
        //     is not a member of System.Windows.Forms.MessageBoxIcon.-or- The defaultButton
        //     specified is not a member of System.Windows.Forms.MessageBoxDefaultButton.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.
        //
        //   System.ArgumentException:
        //     options specified both System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly
        //     and System.Windows.Forms.MessageBoxOptions.ServiceNotification.-or- buttons
        //     specified an invalid combination of System.Windows.Forms.MessageBoxButtons.

        /// <summary>
        /// Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file and Help keyword.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="owner">An implementation of System.Windows.Forms.IWin32Window that will own the modal dialog box.</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the System.Windows.Forms.MessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
        /// <param name="options">One of the System.Windows.Forms.MessageBoxOptions values that specifies which display and association options will be used for the message box. You may pass in 0 if you wish to use the defaults.</param>
        /// <param name="helpFilePath">The path and name of the Help file to display when the user clicks the Help button.</param>
        /// <param name="keyword">The Help keyword to display when the user clicks the Help button.</param>
        /// <returns></returns>
        public static DialogResult Show(bool? isDebug, IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, string keyword)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options, helpFilePath, keyword);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     buttons is not a member of System.Windows.Forms.MessageBoxButtons.-or- icon
        //     is not a member of System.Windows.Forms.MessageBoxIcon.-or- The defaultButton
        //     specified is not a member of System.Windows.Forms.MessageBoxDefaultButton.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.
        //
        //   System.ArgumentException:
        //     options specified both System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly
        //     and System.Windows.Forms.MessageBoxOptions.ServiceNotification.-or- buttons
        //     specified an invalid combination of System.Windows.Forms.MessageBoxButtons.

        /// <summary>
        /// Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file, HelpNavigator, and Help topic.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the System.Windows.Forms.MessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
        /// <param name="options">One of the System.Windows.Forms.MessageBoxOptions values that specifies which display and association options will be used for the message box. You may pass in 0 if you wish to use the defaults.</param>
        /// <param name="helpFilePath">The path and name of the Help file to display when the user clicks the Help button.</param>
        /// <param name="navigator">One of the System.Windows.Forms.HelpNavigator values.</param>
        /// <param name="param">The numeric ID of the Help topic to display when the user clicks the Help button.</param>
        /// <returns></returns>
        public static DialogResult Show(bool? isDebug, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator, object param)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(text, caption, buttons, icon, defaultButton, options, helpFilePath, navigator, param);
        }

        // Exceptions:
        //   System.ComponentModel.InvalidEnumArgumentException:
        //     buttons is not a member of System.Windows.Forms.MessageBoxButtons.-or- icon
        //     is not a member of System.Windows.Forms.MessageBoxIcon.-or- The defaultButton
        //     specified is not a member of System.Windows.Forms.MessageBoxDefaultButton.
        //
        //   System.InvalidOperationException:
        //     An attempt was made to display the System.Windows.Forms.MessageBox in a process
        //     that is not running in User Interactive mode. This is specified by the System.Windows.Forms.SystemInformation.UserInteractive
        //     property.
        //
        //   System.ArgumentException:
        //     options specified both System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly
        //     and System.Windows.Forms.MessageBoxOptions.ServiceNotification.-or- buttons
        //     specified an invalid combination of System.Windows.Forms.MessageBoxButtons.

        /// <summary>
        /// Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file, HelpNavigator, and Help topic.
        /// </summary>
        /// <param name="isDebug">TRUE: Shows debug info</param>
        /// <param name="owner">An implementation of System.Windows.Forms.IWin32Window that will own the modal dialog box.</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the System.Windows.Forms.MessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
        /// <param name="options">One of the System.Windows.Forms.MessageBoxOptions values that specifies which display and association options will be used for the message box. You may pass in 0 if you wish to use the defaults.</param>
        /// <param name="helpFilePath">The path and name of the Help file to display when the user clicks the Help button.</param>
        /// <param name="navigator">One of the System.Windows.Forms.HelpNavigator values.</param>
        /// <param name="param">The numeric ID of the Help topic to display when the user clicks the Help button.</param>
        /// <returns></returns>
        public static DialogResult Show(bool? isDebug, IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator, object param)
        {
            if (isDebug.IsNull()) isDebug = defaultDebugMode;
            if (isDebug.Value) AddDebugInfo(ref text, ref caption);
            return MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options, helpFilePath, navigator, param);
        }
        #endregion
        #endregion
    }
}

// add new enums to shorten params - RKD
